package web.controller;

import java.util.HashMap;

import com.alibaba.fastjson.JSON;
import com.jfinal.aop.Before;
import com.jfinal.core.ActionKey;
import com.jfinal.kit.HttpKit;

import exception.OpensnsException;
import web.common.BaseController;
import web.interceptor.AuthInterceptor;

public class AuthController extends BaseController {
	/**
	* @Title: index
	* @Description: 验证提交数据
	* @author yangyw
	* @throws
	*/
	@Before(AuthInterceptor.class)
	@ActionKey("/v3/user/get_info")
	public void index() {
		System.out.println(JSON.toJSONString(getParaNames()));
		System.out.println(JSON.toJSONString(getParaMap()));
		renderJson(getParaNames());
	}

	/**
	 * @throws OpensnsException @Title: generate @Description: 生成提交数据 @author
	 * yangyw @throws
	 */
	public void testpost() throws OpensnsException {
		// 应用基本信息
		String appid = "123456";
		String appkey = "228bf094169a40a3bd188ba37ebe8723" + "&";
		String scriptName = "/v3/user/get_info";
		HashMap<String, String> params = new HashMap<>();
		params.put("openid", "11111111111111111");
		params.put("openkey", "2222222222222222");
		params.put("pf", "qzone");
		params.put("appid", appid);
		params.put("format", "json");
		params.put("userip", "112.90.139.30");
		
		String sig = kit.token.SnsSigCheck.makeSig("GET", scriptName, params, appkey);
		params.put("sig", sig);
		HttpKit.get("http://127.0.0.1/jfinal-auth-api" + scriptName, params);
		renderNull();
	}
}
